<?php

namespace App\Transformers\Auth\ModuleButton;

use App\Entities\Auth\ModuleButton;
use League\Fractal\TransformerAbstract;

class TreeTransformer extends TransformerAbstract
{
    public function transform(ModuleButton $model)
    {
        return [
            'id' => $model->module_button_id,
            'type' => 'button',
            'parent_id' => null == $model->parent_id ? $model->module_id : $model->parent_id,
            'label' => 'button_'.$model->module_button_id,
            'name' => $model->full_name,
            'route' => $model->action_address,
        ];
    }
}
